function [V_inst, N_i, sub_bin]=calc_V_inst2(params, A_t, Nbar_i, CollPerc_t, Pol_t,  Own_t, Inc_t, ...
    Sunit_t, Scost_t, Skwh_t, P_t, PSale_t, PIns_t, PIns0_t)

global  net_metering C over_dist PV_hh PV
%global state_max   statetaxcredit_t statemaxtaxcredit_t sunit_cap_t

[ sigma, gamma_0, gamma_coll, gamma_pol, gamma_own, gamma_inc, gamma_N, gamma_2N]=unpack_params(params);

%optimal number of panels
N_i=solve_N_i(Nbar_i, A_t, Scost_t, Sunit_t, P_t, PSale_t, PIns0_t, PIns_t, Skwh_t, gamma_N, gamma_2N);


sub=calc_sub(N_i, A_t,  ...
    Sunit_t, Scost_t, Skwh_t, P_t, PSale_t, PIns_t, PIns0_t);




V_inst=sub+N_i.*A_t.*(P_t)-(PIns0_t+ PIns_t.*N_i)+...
    gamma_0+ gamma_coll.*CollPerc_t+gamma_pol.*Pol_t +gamma_own.*Own_t +gamma_inc.*Inc_t + gamma_N.*N_i + gamma_2N.*N_i.*N_i;

if over_dist==1  % adjust because households discount future subsidies
    sub_HH=sub-N_i.*A_t.*(Skwh_t)+(PV_hh./PV).*N_i.*A_t.*(Skwh_t);  

    V_inst=sub_HH+N_i.*A_t.*(P_t)-(PIns0_t+ PIns_t.*N_i)+...
    gamma_0+ gamma_coll.*CollPerc_t+gamma_pol.*Pol_t +gamma_own.*Own_t +gamma_inc.*Inc_t + gamma_N.*N_i + gamma_2N.*N_i.*N_i;
end


if net_metering==1

    A_grid_frac=N_i*C;
    A_grid_frac(A_grid_frac>1)=1;
    
    P_tilde_i=A_grid_frac.*PSale_t + (1-A_grid_frac).*P_t;
    
    V_inst=sub+N_i.*A_t.*(P_tilde_i)-(PIns0_t+ PIns_t.*N_i)+...
    gamma_0+ gamma_coll.*CollPerc_t+gamma_pol.*Pol_t +gamma_own.*Own_t  +gamma_inc.*Inc_t + gamma_N.*N_i + gamma_2N.*N_i.*N_i;
    
end

V_inst=V_inst./sigma;


V_inst(Nbar_i==0)=-100;

if sum(isnan(V_inst)>0)
    stop
end

sub_bin=sub;